package main

import (
	"fmt"
	jsoniter "github.com/json-iterator/go"
	"github.com/valyala/fasthttp"
	"os"
)

var json = jsoniter.ConfigFastest

var Response struct {
	Ret  int    `json:"ret"`
	Msg  string `json:"msg"`
	Info Info   `json:"info"`
}

type Value struct {
	Vid  int    `json:"vid"`
	Name string `json:"name"`
}
type Specs struct {
	Pid   int     `json:"pid"`
	Name  string  `json:"name"`
	Value []Value `json:"value"`
}
type Product struct {
	ProductID       string        `json:"product_id"`
	Status          string        `json:"status"`
	Name            string        `json:"name"`
	SaleType        string        `json:"sale_type"`
	ServiceType     string        `json:"service_type"`
	NeedCheckFollow string        `json:"need_check_follow"`
	Specs           []Specs       `json:"specs"`
	Props           []interface{} `json:"props"`
	Summary         string        `json:"summary"`
	Desc            string        `json:"desc"`
	PicURL          []string      `json:"pic_url"`
	RateNum         string        `json:"rate_num"`
	SaleNum         string        `json:"sale_num"`
	VisitNum        string        `json:"visit_num"`
	FavorNum        string        `json:"favor_num"`
	ExpressFee      string        `json:"express_fee"`
	ActivityPrice   string        `json:"activity_price"`
	JifenPrice      string        `json:"jifen_price"`
	Jifen           string        `json:"jifen"`
	SalePrice       string        `json:"sale_price"`
	Price           string        `json:"price"`
	ProductTag      string        `json:"product_tag"`
	UpTime          string        `json:"up_time"`
	DownTime        string        `json:"down_time"`
	TotalQuantity   string        `json:"total_quantity"`
	Quantity        string        `json:"quantity"`
}
type ItemInfo struct {
	SkuID            string `json:"sku_id"`
	ActivityPrice    int    `json:"activity_price"`
	Price            int    `json:"price"`
	SalePrice        int    `json:"sale_price"`
	JifenPrice       int    `json:"jifen_price"`
	Jifen            int    `json:"jifen"`
	Quantity         string `json:"quantity"`
	OpenDays         int    `json:"open_days"`
	SupportAccount   string `json:"support_account"`
	PicFull          string `json:"pic_full"`
	PicOri           string `json:"pic_ori"`
	ProvideOfferid   string `json:"provide_offerid"`
	GameTag          string `json:"game_tag"`
	SupportRole      string `json:"support_role"`
	SupportPartition string `json:"support_partition"`
	SupportArea      string `json:"support_area"`
	SupportAcct      string `json:"support_acct"`
}

type Info struct {
	Product Product             `json:"product"`
	Item    map[string]ItemInfo `json:"item"`
}

func main() {
	o, err := os.OpenFile("output.js", os.O_CREATE|os.O_WRONLY, 0644)
	if err != nil {
		panic(err)
	}
	for _, i := range []int{
		4380,
		4238,
		4689,
		4239,
		3836,
		4364,
		4363,
		4646,
		3779,
		4650,
		4648,
		4052,
		4681,
		4645,
		4643,
		4145,
		3835,
		4028,
		3839,
		5218,
	} {
		sCode, data, err := fasthttp.Get(nil, fmt.Sprintf("https://jifen.qq.com/cgi-bin/get_goods?pf=vip_m-jifen-html5&pfkey=pfkey&from_h5=1&session_token=4498B069-4252-40EC-8E7F-3EF50AD7D2DC1626223940157&r=0.882811085136973&openid=767763591&openkey=%%40aFWh7LwLm&session_id=uin&session_type=skey&product_id=%d&md=yd.xp&encrypt_msg=764cfab69384e5c4d76f82cf9920d7f5e60091ef20f005ea50472b478e45e34d9eff6654540a8838561d907922c170eb0f33ec818ced211d131bd8296e6370502f0c14bc852b2013f7db0396f0f19023&msg_len=70&offer_id=1450001214&fun=_h5pay18245", i))
		if err != nil {
			panic(err)
		}
		if sCode != fasthttp.StatusOK {
			panic(sCode)
		}
		o.Write(data)
		o.WriteString("\n")
	}
}
